<?php
$table = \Phpcmf\Service::M()->prefix.'attachment_folder';
// 创建字段
if (!\Phpcmf\Service::M()->db->tableExists($table)) {
    \Phpcmf\Service::M()->db->simpleQuery(trim("CREATE TABLE IF NOT EXISTS `".$table."` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `folder_name` varchar(100) NOT NULL COMMENT '文件夹名',
      `description` varchar(100) NOT NULL COMMENT '描述',
      `port_level` int(10) unsigned NOT NULL COMMENT '高度',
      `parent_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '父文档id',
      `is_directory` int(10) unsigned NOT NULL COMMENT '文件类型标志位',
      `crt_uid` mediumint(8) unsigned NOT NULL COMMENT '第一个作者uid',
      `upd_uid` mediumint(8) unsigned NOT NULL COMMENT '作者uid',
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='附件操作记录表';"));
}
$table = \Phpcmf\Service::M()->prefix.'attachment';
if (\Phpcmf\Service::M()->db->tableExists($table) &&
    !\Phpcmf\Service::M()->db->fieldExists('parent_id', $table)
    ){
    \Phpcmf\Service::M()->query('ALTER TABLE `' . $table . '` ADD `parent_id` int(10)  DEFAULT 0 COMMENT \'父文档id\';');
}
\Phpcmf\Service::M('cache')->sync_cache('');

